package com.loongtech.bi.manager.game;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.loongtech.bi.entity.game.EntityActiveUserCurrencyConsume;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
/**
 * 
 * @author lihui
 *
 */
@Service
public class ActiveUserCurrencyConsumeManager extends ManagerQueryCacheBase<EntityActiveUserCurrencyConsume> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 
	 * @param dateStart
	 * @param dateEnd
	 * @param queryPlatform
	 * @param queryChannel
	 * @param queryServer
	 * @return
	 */
	public List<Long> getSumData(Date dayStart, Date dayEnd,String queryPlatform, String queryChannel, String queryServer,String currencytype) {
		return findByQuery("select coalesce(sum(consume),0) from EntityActiveUserCurrencyConsume where day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' and currencytype = "+currencytype+" ","dayStart", dayStart, "dayEnd", dayEnd);
	}
	
	public List<Object[]> getListData(Date dayStart, Date dayEnd,String queryPlatform, String queryChannel, String queryServer,String currencytype) {
		return findByQuery("select date_format(day,'%Y-%m-%d'),consume from EntityActiveUserCurrencyConsume where day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' and currencytype = "+currencytype+" ","dayStart", dayStart, "dayEnd", dayEnd);
	}
}
